package com.singularity.common.service;

import com.singularity.common.domain.entity.Attachment;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * @author 天
 *
 * @description: 附件相关接口
 */
public interface AttachmentService {

    /**
     * 文件上传
     * @param multipartFile
     * @param ownerType
     * @param ownerId
     * @return
     */
    Attachment uploadAttachment(MultipartFile multipartFile,String ownerType,Long ownerId);

    /**
     * 批量文件上传
     * @param multipartFileList
     * @param ownerType
     * @param ownerId
     * @return
     */
    List<Attachment> uploadAttachmentList(List<MultipartFile> multipartFileList,String ownerType,Long ownerId);

    /**
     * 获取附件
     * @param ownerType
     * @param ownerId
     * @return
     */
    List<Attachment> getAttachment(String ownerType,Long ownerId);

    /**
     * 获取附件预览路径(默认一小时)
     * @param objName
     * @param expiryTime
     * @return
     */
    String getAttachmentUrl(String objName,Integer expiryTime);

    /**
     * 下载附件
     * @param objName
     * @return
     */
    InputStream downloadAttachment(String objName);

    /**
     * 删除附件
     * @param ownerType
     * @param ownerId
     * @return
     */
    int removeAttachment(String ownerType, Long ownerId);

    /**
     * 更新附件
     * @param attachmentId
     * @param multipartFile
     * @return
     */
    Attachment updateAttachment(Long attachmentId,MultipartFile multipartFile);
}
